//
// Created by lenovo on 2021/11/28.
//
void fun(int *a, int n, int *odd, int *even);

#include "process.h"
#include "stdio.h"
#define N 20

int experiment6_1() {
    int a[N] = {1, 9, 2, 3, 11, 6}, i, n = 6, odd, even;
    //n为数组长度，odd为奇数和，even为偶数和
    printf("The original data is:\n");
    for (i = 0; i < n; i++)
        printf("%5d", *(a + i));
    printf("\n\n");
    fun(a, n, &odd, &even);//调用函数计算偶数和与奇数和
    printf("The sum of odd numbers:%d\n", odd);
    printf("The sum of even number:%d\n", even);
    system("pause");
}

void fun(int *a, int n, int *odd, int *even) {
    *odd = 0, *even = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] % 2 == 0) {
            *even += a[i];
        } else *odd += a[i];
    }
}
